home *** CD-ROM | disk | FTP | other *** search
/ Openstep 4.2 (Developer) / Openstep Developer 4.2.iso / NextDeveloper / Source / GNU / uucp / Uucp.framework / uuconf.subproj / syshdr.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-20  |  4.3 KB  |  141 lines

  1. /* syshdr.unx -*- C -*-
  2.    Unix system header for the uuconf library.
  3.  
  4.    Copyright (C) 1992, 1993 Ian Lance Taylor
  5.  
  6.    This file is part of the Taylor UUCP uuconf library.
  7.  
  8.    This library is free software; you can redistribute it and/or
  9.    modify it under the terms of the GNU Library General Public License
  10.    as published by the Free Software Foundation; either version 2 of
  11.    the License, or (at your option) any later version.
  12.  
  13.    This library is distributed in the hope that it will be useful, but
  14.    WITHOUT ANY WARRANTY; without even the implied warranty of
  15.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.    Library General Public License for more details.
  17.  
  18.    You should have received a copy of the GNU Library General Public
  19.    License along with this library; if not, write to the Free Software
  20.    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  21.  
  22.    The author of the program may be contacted at ian@airs.com or
  23.    c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
  24.    */
  25.  
  26. /* The root directory (used when setting local-send and local-receive
  27.    values).  */
  28. #define ZROOTDIR "/"
  29.  
  30. /* The current directory (used by uuconv as a prefix for the newly
  31.    created file names).  */
  32. #define ZCURDIR "."
  33.  
  34. /* The names of the Taylor UUCP configuration files.  These are
  35.    appended to NEWCONFIGLIB which is defined in Makefile.  */
  36. #define CONFIGFILE "/config"
  37. #define SYSFILE "/sys"
  38. #define PORTFILE "/port"
  39. #define DIALFILE "/dial"
  40. #define CALLFILE "/call"
  41. #define PASSWDFILE "/passwd"
  42. #define DIALCODEFILE "/dialcode"
  43.  
  44. /* The names of the various V2 configuration files.  These are
  45.    appended to OLDCONFIGLIB which is defined in Makefile.  */
  46. #define V2_SYSTEMS "/L.sys"
  47. #define V2_DEVICES "/L-devices"
  48. #define V2_USERFILE "/USERFILE"
  49. #define V2_CMDS "/L.cmds"
  50. #define V2_DIALCODES "/L-dialcodes"
  51.  
  52. /* The names of the HDB configuration files.  These are appended to
  53.    OLDCONFIGLIB which is defined in Makefile.  */
  54. #define HDB_SYSFILES "/Sysfiles"
  55. #define HDB_SYSTEMS "/Systems"
  56. #define HDB_PERMISSIONS "/Permissions"
  57. #define HDB_DEVICES "/Devices"
  58. #define HDB_DIALERS "/Dialers"
  59. #define HDB_DIALCODES "/Dialcodes"
  60. #define HDB_MAXUUXQTS "/Maxuuxqts"
  61. #define HDB_REMOTE_UNKNOWN "/remote.unknown"
  62.  
  63. /* A string which is inserted between the value of OLDCONFIGLIB
  64.    (defined in the Makefile) and any names specified in the HDB
  65.    Sysfiles file.  */
  66. #define HDB_SEPARATOR "/"
  67.  
  68. /* A macro to check whether fopen failed because the file did not
  69.    exist.  */
  70. #define FNO_SUCH_FILE() (errno == ENOENT)
  71.  
  72. #if ! HAVE_STRERROR
  73.  
  74. /* We need a definition for strerror; normally the function in the
  75.    unix directory is used, but we want to be independent of that
  76.    library.  This macro evaluates its argument multiple times.  */
  77. extern int sys_nerr;
  78. extern char *sys_errlist[];
  79.  
  80. #define strerror(ierr) \
  81.   ((ierr) >= 0 && (ierr) < sys_nerr ? sys_errlist[ierr] : "unknown error")
  82.  
  83. #endif /* ! HAVE_STRERROR */
  84.  
  85. /* This macro is used to make a filename found in a configuration file
  86.    into an absolute path.  The zdir argument is the directory to put it
  87.    in.  The zset argument is set to the new string.  The fallocated
  88.    argument is set to TRUE if the new string was allocated.  */
  89. #define MAKE_ABSOLUTE(zset, fallocated, zfile, zdir, pblock) \
  90.   do \
  91.     { \
  92.       if (*(zfile) == '/') \
  93.     { \
  94.       (zset) = (zfile); \
  95.       (fallocated) = FALSE; \
  96.     } \
  97.       else \
  98.     { \
  99.       size_t abs_cdir, abs_cfile; \
  100.       char *abs_zret; \
  101. \
  102.       abs_cdir = strlen (zdir); \
  103.       abs_cfile = strlen (zfile); \
  104.       abs_zret = (char *) uuconf_malloc ((pblock), \
  105.                          abs_cdir + abs_cfile + 2); \
  106.       (zset) = abs_zret; \
  107.       (fallocated) = TRUE; \
  108.       if (abs_zret != NULL) \
  109.         { \
  110.           memcpy ((pointer) abs_zret, (pointer) (zdir), abs_cdir); \
  111.           abs_zret[abs_cdir] = '/'; \
  112.           memcpy ((pointer) (abs_zret + abs_cdir + 1), \
  113.               (pointer) (zfile), abs_cfile + 1); \
  114.         } \
  115.     } \
  116.     } \
  117.   while (0)
  118.  
  119. /* We want to be able to mark the Taylor UUCP system files as close on
  120.    exec.  */
  121. #if HAVE_FCNTL_H
  122. #include <fcntl.h>
  123. #else
  124. #if HAVE_SYS_FILE_H
  125. #include <sys/file.h>
  126. #endif
  127. #endif
  128.  
  129. #ifndef FD_CLOEXEC
  130. #define FD_CLOEXEC 1
  131. #endif
  132.  
  133. #define CLOSE_ON_EXEC(e) \
  134.   do \
  135.     { \
  136.       int cle_i = fileno (e); \
  137.  \
  138.       fcntl (cle_i, F_SETFD, fcntl (cle_i, F_GETFD, 0) | FD_CLOEXEC); \
  139.     } \
  140.   while (0)
  141.